home *** CD-ROM | disk | FTP | other *** search
- /* strstr.c From TC Bible page 300 Use strstr to locate the first occurrence
- of one string in another. */
-
- #include <stdio.h>
- #include <string.h>
- main()
- {
- char str1[80], str2[80], *result;
- printf("Enter a string: ");
- gets(str1);
- printf("Enter a string to locaate in the first: ");
- gets(str2);
- if((result = strstr(str1, str2)) == NULL)
- {
- printf("\"%s\" NOT IN \"%s\"\n", str2, str1);
- }
- else
- {
- printf("\"%s\" FOUND.\n\Rest of string: %s\n",
- str2, result);
- }
- }